<!--安排工廠-->
            <div class="modal fade" id="middle_report_add" tabindex="-1" role="dialog" aria-labelledby="businessFileModalLabel" aria-hidden="true">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
								&times;
							</button>
							<h4 class="modal-title" id="businessFileModalLabel">
								上传中查报告
							</h4>
						</div>
						<div class="modal-body">
						<form id="middle_report_add_form" enctype="multipart/form-data">
						<div class="row">
                                        <div class="col-lg-6">
                                            <div class="form-group">
                                            <input type="file" id="middleReportfile" name="file" class="form-control"  />
                                        </div>
                                        </div><!-- /.col-lg-6 -->
                                        <div class="col-lg-6">
                                            <div class="form-group">
                                                <button onclick="uploadMiddleReport();" type="button" class="btn btn-primary">上传</button>
                                            </div><!-- /input-group -->
                                        </div><!-- /.col-lg-6 -->
                                    </div>
						
							
			            </form>
			            <table class="table table-bordered" id="middle_report_rowdata">
                                        <tr >
                                            <th style="width: 60px">序号</th>
                                            <th>文件名</th>
                                            <th>上传时间</th>
                                            <th style="width: 60px">操作</th>
                                        </tr>
                                       
                                        </table>	
						</div>
						<div class="modal-footer">
							
							<button type="button" class="btn btn-default" data-dismiss="modal">
								关闭
							</button>
						</div>
					</div><!-- /.modal-content -->
				</div><!-- /.modal -->
			</div>
			  <script type="text/javascript">
        function addMiddleReport(){
        	
        	
        	loadMiddleReport();
        	$('#middle_report_add').modal({
    			keyboard: true
    		});
        }
        
        function loadMiddleReport(){

        	$.ajax({
                type: "POST",
                dataType: "json",
                url: "../businessfile/selectlist",
                data:{businessId:$("#productionPatternId").val(),category:'scm_production_pattern-middle_report'},
                
                success : function(map) {  
                	if(map.head.respCode=="0000000"){
                		var trObjs = $("#middle_report_rowdata tr");
                		if(trObjs.length>1){
                			for(var i =1;i<trObjs.length;i++){
                				trObjs[i].remove();
                			}
                			
                		}
	                	for(var i =0;i<map.body.length;i++){
	                		var data = map.body[i];
	                		$("#middle_report_rowdata").append("<tr><td>"+(i+1)+"</td><td>"+data.originName+"</td><td>"+data.createdAt+"</td><td><i title='下载' class='fa fa-fw fa-download'></i><i title='删除' class='fa fa-fw fa-minus-circle'></i></td></tr>");
	                	}
	                }else{
	                	alert(map.body);
	                }
	            },  
	            error : function(map) {  
	                alert("出现错误，请刷新页面");  
	            }  

            });
        }
        function uploadMiddleReport(){
        	if($("#middleReportfile").val()==""){
        		alert("请选择文件");
        		return;
        	}
        	$("#middle_report_add_form").ajaxSubmit({
                type: "POST",
                dataType: "json",
                url: "../businessfile/insert",
                data:{businessId:$("#productionPatternId").val(),category:'scm_production_pattern-middle_report',flag:0},
                
                success : function(map) {  
                	if(map.head.respCode=="0000000"){
	                	alert("保存成功");
	                	loadMiddleReport()
	                }else{
	                	alert(map.body);
	                }
	            },  
	            error : function(map) {  
	                alert("出现错误，请刷新页面");  
	            }  

            });
        }
        
        </script>